package com.uzai.console.web.report;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.converters.longconverter.LongStringConverter;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.common.exception.BusinessException;
import com.uzai.common.result.ResponseCode;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.common.ResponseMsg;
import com.uzai.console.common.utils.Tools;
import com.uzai.console.common.utils.ZipUtils;
import com.uzai.console.constant.Const;
import com.uzai.console.dto.device.DeviceQuery;
import com.uzai.console.dto.report.FansValueIndicatorDto;
import com.uzai.console.dto.report.FansValueReportExportResultDto;
import com.uzai.console.dto.report.FansValueReportQuery;
import com.uzai.console.dto.report.RobotDataReportQuery;
import com.uzai.console.dto.stats.OrderProfitStatsDto;
import com.uzai.console.dto.stats.OrderProfitStatsQuery;
import com.uzai.console.dto.tb.tbpunishorder.TbPunishOrderExportResultDto;
import com.uzai.console.dto.tb.tbpunishorder.TbPunishOrderQuery;
import com.uzai.console.entity.Merchant;
import com.uzai.console.entity.TbPunishOrder;
import com.uzai.console.entity.TbToken;
import com.uzai.console.enums.*;
import com.uzai.console.service.device.DeviceService;
import com.uzai.console.service.report.FansValueReportService;
import com.uzai.console.service.report.RobotDataReportService;
import com.uzai.console.vo.device.DeviceInfoVo;
import com.uzai.console.vo.exportinfo.ExportAmountVo;
import com.uzai.console.vo.report.FansValueReportVo;
import com.uzai.console.vo.report.RobotDataReportVo;
import com.uzai.console.vo.stats.orderprofit.OrderProfitPageVo;
import com.uzai.console.vo.stats.orderprofit.OrderProfitStatsVo;
import com.uzai.console.vo.tb.tbpunishorder.TbPunishOrderExport;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.tools.zip.ZipOutputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * 粉丝价值
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "粉丝价值",tags = "数据报表|粉丝价值")
@ApiSort(50)
@RestController
public class FansValueReportController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(FansValueReportController.class);

    @Autowired
    private DeviceService deviceService;
    @Autowired
    private FansValueReportService fansValueReportService;

    @ApiOperation(value = "查询机器人下拉列表", notes = "查询机器人下拉列表", response = DeviceInfoVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/report/fansValue/findDeviceList")
    public Object findDeviceList(@RequestBody DeviceQuery deviceQuery) {
        deviceQuery.setMerId(getLoginInfo().getMerId());
        return deviceService.findDeviceList(deviceQuery);
    }

    @ApiOperation(value = "分页查询粉丝价值报表", notes = "分页查询粉丝价值报表", response = FansValueReportVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/report/fansValueReport")
    public Object fansValueReport(@RequestBody FansValueReportQuery fansValueReportQuery){
        return fansValueReportService.fansValueReport(fansValueReportQuery);
    }

    @ApiOperation(value = "统计粉丝价值指标", notes = "统计粉丝价值指标", response = FansValueReportVo.class)
    @ApiOperationSupport(order = 3)
    @PostMapping("/report/fansValueIndicator")
    public Object fansValueIndicator(@RequestBody FansValueIndicatorDto fansValueIndicatorDto){
        return fansValueReportService.fansValueIndicator(fansValueIndicatorDto);
    }

    @ApiOperation(value = "粉丝价值报表查询结果导出文件前检验接口", notes = "粉丝价值报表查询结果导出文件前检验接口", response = ExportAmountVo.class)
    @ApiOperationSupport(order = 4)
    @PostMapping("/report/fansValue/getExportAmount")
    public Object getExportAmount(@RequestBody FansValueReportQuery fansValueReportQuery){
        return fansValueReportService.getExportAmount(fansValueReportQuery);
    }

    @SystemLogType(model = SystemModelEnum.FansValueReport, type = OperationTypeEnum.EXPORT)
    @ApiOperation(value = "粉丝价值报表查询结果导出文件", notes = "粉丝价值报表查询结果导出文件")
    @ApiOperationSupport(order = 5)
    @PostMapping("/report/fansValue/exportByQeuryResult")
    public Object exportByQeuryResult(@RequestBody FansValueReportExportResultDto fansValueReportExportResultDto){
        fansValueReportService.exportByQeuryResult(fansValueReportExportResultDto);
        return true;
    }


}
